package values.avatar
{
import core.Configuration;
import core.Language;

import flash.utils.Dictionary;

/**
 * AvatarTypeValue
 * @author jliang
 *
 */
public class AvatarTypeValue
{
	[Data(type="field", mapping="@key")]
	public var key:String;
	
	[Data(type="field", mapping="@name")]
	public var baseNameKey:String;
	
	public function get name():String
	{
		return Language.getText(baseNameKey);
	}
	
	[Data(type="field", mapping="@desc")]
	public var baseDescKey:String;
	
	public function get desc():String
	{
		return Language.getText(baseDescKey);
	}
	
	[Data(type="field" , mapping="@main_property")]
	public var mainProperty:String;
	
	[Data(type="field", mapping="@icon")]
	public var baseIconPath:String;
	
	public function get icon():String
	{
		return Configuration.assetsPath + baseIconPath;
	}
	
	[Data(type="field", mapping="@chooseable")]
	public var chooseable:Boolean;
	
	protected var _equipPositions:Dictionary;
	
	public function get equipPositions():Dictionary
	{
		return _equipPositions;
	}
	
	protected var supportEquips:Dictionary = new Dictionary(true);
	
	[Data(type="mapping", 
			  mapping="equip_position.position", 
			  ref="values.avatar.AvatarEquipPositionValue",
			  way="one_to_more",
			  object="flash.utils.Dictionary",
	          key="@key")]
	public function set equipPositions(value:Dictionary):void
	{
		_equipPositions = value;
		
		for each (var position:AvatarEquipPositionValue in equipPositions)
		{
			for each (var type:String in position.supportEquipTypes)
			{
				supportEquips[type] = true;
			}
		}
	}
	
	public function getPositionByKey(key:String):AvatarEquipPositionValue
	{
		return equipPositions[key];
	}
	
	public function canSupportEquip(equipType:String):Boolean
	{
		return supportEquips[equipType] == true;
	}
}
}



